package com.zhentao.controller;

import com.zhentao.file.service.FileStorageService;
import com.zhentao.model.dtos.ResponseResult;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

@RestController
@RequestMapping("/minio")
public class MinioTestController {
    @Autowired
    private FileStorageService fileStorageService;

    @SneakyThrows
    @RequestMapping("/uploadHtml")
    public ResponseResult uploadHtml(){
        try {
            FileInputStream inputStream = new FileInputStream("C://Users//86132//Desktop//03.html");
            String url = fileStorageService.uploadHtmlFile("03.html", inputStream);
            return ResponseResult.okResult(url);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return ResponseResult.errorResult(303, "minio异常");
        }


    }

}

























